/**
 * 获得下一级地址分类
 */
var hotspot = new Object(); 

hotspot.getSubAdddr = function(rid, type)
{
  Ajax.call('nav.php', 'act=list'+'&type=' + type + "&rid=" + rid , hotspot.listResponse, "GET", "JSON");
}

hotspot.listResponse = function(result, text_result)
{
  //var div_type = document.getElementById('hotspot-type');
  var div_ele = document.getElementById('hot-spot-box');
//  var div_add  = "<div class='hotspot-frame'>"+
//                        "<div id='hotspot-type' class='hotspot-type'>热点写字楼</div>"+
//                        "<div id='hotspot-name' class='hotspot-name'>"+
//                            "<a href='#'>双子塔</a>"+
//                            "<a href='#'>唯品楼</a>"+
//                            "<a href='#'>罗生门</a>"+
//                            "<a href='#'>大明湖畔</a>"+
//                            "<a href='#'>鲁迅楼</a>"+
//                            "<a href='#'>巴黎铁塔</a>"+
//                            "<a href='#'>自由女神</a>"+
//                            "<a href='#'>纽交所</a>"+
//                        "</div>"+
//                    "</div>";
  var div_add  = "";
  var hotspots = new Array('','','','','','','');
  var hotspots_main = new Array('请选择类型','热点写字楼','热点商场','热点住宅区','热点院校','热点网吧','其它');
  if(result.hotspots.length > 0){
         
        for(var i in result.hotspots){
            
            for(var j = 1; j < hotspots_main.length; j++){
                
                if(result.hotspots[i].hotspot_type == j){
                    
                	//hotspots[j] = "";
                    hotspots[j] += "<a href='brand.php?hotspot="+result.hotspots[i].hotspot_type+"-"+result.hotspots[i].region_id+"'>"+result.hotspots[i].region_name+"</a>";
                }
            }
        }
        var div_add = "";
        for(var k = 1; k < hotspots.length; k++){
            
            if(hotspots[k] != ''){
                
                hotspots[k] = "<div class='hotspot-frame'><div class='hotspot-type'>"
                	+hotspots_main[k]+"</div><div class='hotspot-name'>"+hotspots[k]+"</div></div>";
                div_add += hotspots[k];
            }   
            
        }
  }else {
	  
	  var div_add  = "<div class='hotspot-frame'>"+
				    "<div id='hotspot-type' class='hotspot-type'></div>"+
				    "<div id='hotspot-name' class='hotspot-name'>"+
				        "<span>该地区还没有热点地区哦！</span>"+
				    "</div>"+
				"</div>";
	  
  }
  if(div_add != ""){
      
      div_ele.innerHTML = "";
      div_ele.innerHTML = div_add;
  }
  //console.log(div_add);
}

getSubAdddr_FromRegion = function(parent, type, target)
{
    var rid = parent.options[parent.selectedIndex].value;
    if(rid > 0){
        
        Ajax.call('../nav.php', 'act=list'+'&type=' + type +'&target=' + target+ "&rid=" + rid , hotspot.listResponse_ToRegion, "GET", "JSON");
    }
    
}

hotspot.listResponse_ToRegion = function(result)
{
  var div_ele       = document.getElementById(result.target);
  div_ele.innerHTML = "";
  var div_add       = "";
  var hotspots_main = new Array('请选择类型','热点写字楼','热点商场','热点住宅区','热点院校','热点网吧','其它');
  if(result.hotspots.length > 0){
         
        for(var i in result.hotspots){
            
            for(var j = 1; j < hotspots_main.length; j++){
                
                if(result.hotspots[i].hotspot_type == j){
                    
                    var opt   = document.createElement('OPTION');
                    opt.text  = hotspots_main[j]+"  "+result.hotspots[i].region_name;
                    opt.value = j+'-'+result.hotspots[i].region_id;
                    div_ele.options.add(opt);
                    //div_add += "<option value='"+j+"-"+
                    //result.hotspots[i].region_id+"'>"+hotspots_main[j]+"  "+result.hotspots[i].region_name+"</option>";
                }
            }
        }

  }else {
      
      //div_add = "<option value='0'>无</option>"
      var opt   = document.createElement('OPTION');
      opt.text  = '无热点地区';
      opt.value = 0;
      div_ele.options.add(opt);
      alert("该地区还没有热点地区哦！");
      
  }
}